home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktimeintro / desktop sprites / start code / animsprite.c next >
Encoding:
C/C++ Source or Header  |  2000-10-06  |  1.0 KB  |  47 lines

  1.  
  2. #ifndef _MAININCLUDES_
  3. #include "main.h"
  4. #endif
  5.  
  6. void MyMoveSprites (void)
  7. {
  8.     short                nIndex;
  9.     MatrixRecord                matrix;
  10.     
  11.     SetIdentityMatrix(&matrix);
  12.  
  13.     // for each sprite
  14.     for (nIndex = 0; nIndex < kNumSprites; nIndex++) {
  15.     
  16.         // modify the sprite’s matrix
  17.         OffsetRect(&gDestRects[nIndex], gDeltas[nIndex].h,
  18.                     gDeltas[nIndex].v);
  19.         
  20.         if ((gDestRects[nIndex].right >= gBounceBox.right) ||
  21.             (gDestRects[nIndex].left <= gBounceBox.left))
  22.             gDeltas[nIndex].h = -gDeltas[nIndex].h;
  23.         
  24.         if ((gDestRects[nIndex].bottom >= gBounceBox.bottom) ||
  25.             (gDestRects[nIndex].top <= gBounceBox.top))
  26.             gDeltas[nIndex].v = -gDeltas[nIndex].v;
  27.         
  28.         matrix.matrix[2][0] = ((long)gDestRects[nIndex].left << 16);
  29.         matrix.matrix[2][1] = ((long)gDestRects[nIndex].top << 16);
  30.         
  31. // Step 4.
  32. // Insert "SetSpriteMatrix.clp" here
  33.  
  34.         
  35.         // change the sprite’s image
  36.         gCurrentImages[nIndex]++;
  37.         if (gCurrentImages[nIndex] >= (kNumSpaceShipImages *
  38.                                         (nIndex+1)))
  39.         {
  40.             gCurrentImages[nIndex] = 0;
  41.         }
  42.         
  43. // Step 5.
  44. // Insert "SetSpriteImage.clp" here
  45.  
  46.     }
  47. }